/*
 *
 *  Copyright (C) 2010 Tal Eisenberg
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package tal.drivechain.chain;

/**
 *
 * @author Main
 */
public class ParallelPatcher extends RolePatcher {
    public void patchNodes(Chain chain) throws IllegalArgumentException, AbortChainException {
        fetchModules(chain);
        if (parsers.size()!=0) {
            for (ChainNode input : inputs) {
                for (ChainNode parser : parsers)
                    input.addOutput(parser);
            } 
            for (ChainNode output : outputs)
                for (ChainNode parser : parsers)
                    parser.addOutput(output);
        } else {
            //no parsers. connect every input to each output.
            for (ChainNode input : inputs) {
                for (ChainNode output : outputs)
                    input.addOutput(output);
            }
        }
    }

}
